package ug.co.icom.kyazze.healthticket;

import java.util.Date;

import ug.co.icom.kyazze.healthticket.DataBase.Database;
import ug.co.icom.kyazze.healthticket.data.Allergy;
import android.app.Activity;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.widget.EditText;

public class GenericAllergyViewer extends Activity{
	private EditText tv_cs_allergy_name;
	private EditText et_cs_diagnosis;
	private EditText et_cs_severity;
	private EditText et_cs_reaction;
	private EditText et_cs_comments;
	private EditText occurence;
	private EditText et_cs_isSynced;
	Database query_handler;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.view_combined_concept);
		
		Intent intent = getIntent();
		String Allergy_Name = intent.getExtras().getString("Allergy_Name");
		
		SQLiteDatabase db = openOrCreateDatabase("mrDB", MODE_PRIVATE, null);
		query_handler = new Database(db);

		Allergy all_object = query_handler.getAllergy(Allergy_Name);
		

		tv_cs_allergy_name = (EditText) findViewById(R.id.tv_cs_allergy_name);
		et_cs_diagnosis = (EditText) findViewById(R.id.et_cs_diagnosis);
		et_cs_severity = (EditText) findViewById(R.id.et_cs_severity);
		et_cs_reaction = (EditText) findViewById(R.id.et_cs_reaction);
		occurence = (EditText) findViewById(R.id.et_occurence);
		et_cs_comments = (EditText) findViewById(R.id.et_cs_comments);
		et_cs_isSynced = (EditText) findViewById(R.id.et_cs_isSynced);
		

		//for (Allergy aobj : all_objects) {

			String allergy_name1 = all_object.getAllergy_name();

			
			Date diagnosis = all_object.getAllergy_date_of_diagnosis();
			String severity = all_object.getAllergy_severity();
			String reaction = all_object.getAllergy_reaction();
			String occurence2 = all_object.getAllergy_occurence();
			String comments = all_object.getAllergy_additional_comments();
			String sync_status = all_object.getIS_Synced();
			
			
			
		
			tv_cs_allergy_name.setText(allergy_name1);
			et_cs_diagnosis.setText(diagnosis.toString());
			et_cs_severity.setText(severity);
			et_cs_reaction.setText(reaction);
			et_cs_comments.setText(comments);
			occurence.setText(occurence2);
			et_cs_isSynced.setText(sync_status);

		//}
		

	}

}
